﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.Revit;
using YArchitech.Revit.RevitExtension;
using YJKRevitBase.WinForm;
using YJKGeometryFuncs;
using YJKExcelFormTool.Kits;
using YJKExcelFormTool.Utilities;

namespace YJKExcelFormTool.Designer
{
	internal class DrawDoorWindowLegendControler
	{
		public DrawDoorWindowLegendControler(ExternalCommandData cmdData)
		{
			this.m_Revit = cmdData;
			this.m_DimensionType = this.GetDimentionType(ref this.m_DimOffset);
			this.m_TextNoteType = this.GetTextNoteType(ref this.m_FontHeight, ref this.m_FontRate);
		}

		public Result CreateSingleLegend(FamilySymbol symbol, int viewTypeIndex, double scale, ref string message)
		{
			DrawLegendKit.ViewSectionType vsType = DrawLegendKit.ViewSectionType.VST_Top;
			switch (viewTypeIndex)
			{
			case 0:
				vsType = DrawLegendKit.ViewSectionType.VST_Top;
				break;
			case 1:
				vsType = DrawLegendKit.ViewSectionType.VST_Front;
				break;
			case 2:
				vsType = DrawLegendKit.ViewSectionType.VST_Back;
				break;
			case 3:
				vsType = DrawLegendKit.ViewSectionType.VST_Left;
				break;
			case 4:
				vsType = DrawLegendKit.ViewSectionType.VST_Right;
				break;
			}
			Document document = this.m_Revit.Application.ActiveUIDocument.Document;
			XYZ xyz = this.SetPositionPoint();
			if (xyz == null)
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			Transaction transaction = new Transaction(document);
			transaction.Start("create single legend");
			DrawDoorWindowLegendControler.LegendInfos legendInfos = this.GetLegendInfos(symbol, vsType, scale);
			this.CreateLegend(legendInfos, xyz);
			transaction.Commit();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		[DllImport("user32.dll")]
		private static extern void BlockInput(bool Block);

		public Result Create(WindowHandle hWndRevit, ref string message)
		{
			List<KeyValuePair<int, string>> list = new List<KeyValuePair<int, string>>();
			List<FamilyInstance> allDoorDelegate = this.GetAllDoorDelegate(ref list);
			List<FamilyInstance> allWindowDelegate = this.GetAllWindowDelegate(ref list);
			double maxLegendWidth = this.GetMaxLegendWidth(allDoorDelegate, allWindowDelegate);
			if (allDoorDelegate.Count + allWindowDelegate.Count == 0)
			{
				message = "当前工程门窗数量为0";
				YJKMessageBox.Show(message);
				return Autodesk.Revit.UI.Result.Succeeded;
			}
			if (YJKExcelFormTool.Utilities.Geometry.IsEqual(maxLegendWidth, 0.0))
			{
				return Autodesk.Revit.UI.Result.Succeeded;
			}
			if (new ViewControler(this.m_Revit, ViewControler.TableViewType.TVT_DOORWINDOWLEGEND).CreateDraftingView(50) == ViewSelectResult.VSR_Cancel)
			{
				return Autodesk.Revit.UI.Result.Failed;
			}
			this.ZoomView(maxLegendWidth);
			Transaction transaction = null;
			PickedBox pickedBox = this.SelectPickedBox();
			if (pickedBox == null)
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			double x = pickedBox.Min.X;
			double x2 = pickedBox.Max.X;
			if (YJKExcelFormTool.Utilities.Geometry.LessThan(x2, x))
			{
				x = pickedBox.Max.X;
				x2 = pickedBox.Min.X;
			}
			double y = pickedBox.Min.Y;
			double y2 = pickedBox.Max.Y;
			if (YJKExcelFormTool.Utilities.Geometry.LessThan(y2, y))
			{
				y = pickedBox.Max.Y;
				y2 = pickedBox.Min.Y;
			}
			XYZ xyz = new XYZ(x, y2, 0.0);
			double num = x2 - x;
			double num2 = this.m_DimOffset + 1.0;
			double extendCol = this.m_DimOffset + this.m_FontHeight;
			if (num < maxLegendWidth + num2 * 2.0)
			{
				YJKMessageBox.Show("宽度不够");
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			transaction = new Transaction(this.m_Revit.Application.ActiveUIDocument.Document);
			transaction.Start("create legend");
			List<KeyValuePair<int, string>> list2 = new List<KeyValuePair<int, string>>();
			KeyValuePair<int, string> item = new KeyValuePair<int, string>(allDoorDelegate.Count, "提取门图例信息");
			list2.Add(item);
			KeyValuePair<int, string> item2 = new KeyValuePair<int, string>(allWindowDelegate.Count, "提取窗图例信息");
			list2.Add(item2);
			KeyValuePair<int, string> item3 = new KeyValuePair<int, string>(allDoorDelegate.Count, "绘制门图例");
			list2.Add(item3);
			KeyValuePair<int, string> item4 = new KeyValuePair<int, string>(allWindowDelegate.Count, "绘制窗图例");
			list2.Add(item4);
			MyProgressBar myProgressBar = new MyProgressBar(hWndRevit, list2, "绘制门窗图例", true);
			double scale = 1.0;
			Dictionary<FamilyInstance, List<Dimension>> dictionary = new Dictionary<FamilyInstance, List<Dimension>>();
			Dictionary<FamilyInstance, List<Dimension>> dictionary2 = new Dictionary<FamilyInstance, List<Dimension>>();
			foreach (FamilyInstance key in allDoorDelegate)
			{
				dictionary.Add(key, null);
			}
			foreach (FamilyInstance key2 in allWindowDelegate)
			{
				dictionary2.Add(key2, null);
			}
			List<DrawDoorWindowLegendControler.LegendRowInfos> legendTableInfos = this.GetLegendTableInfos(dictionary, num, num2, scale, ref myProgressBar);
			List<DrawDoorWindowLegendControler.LegendRowInfos> legendTableInfos2 = this.GetLegendTableInfos(dictionary2, num, num2, scale, ref myProgressBar);
			DrawDoorWindowLegendControler.BlockInput(true);
			XYZ xyz2 = this.CreateLegends(legendTableInfos, xyz, num2, extendCol, ref myProgressBar);
			xyz2 = this.CreateLegends(legendTableInfos2, xyz + xyz2, num2, extendCol, ref myProgressBar);
			DrawDoorWindowLegendControler.BlockInput(false);
			if (myProgressBar.IsStoped)
			{
				transaction.RollBack();
			}
			else
			{
				transaction.Commit();
			}
			myProgressBar.Dispose();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private DimensionType GetDimensionType(string strFamilyName, string strTypeName)
		{
			DimensionType result;
			try
			{
				Document document = this.m_Revit.Application.ActiveUIDocument.Document;
				string strFamilyFilePath = @"C:\Hongye\HYArch2019\FamilyLib\Family" + "\\" + RevitVersion.Version + "\\OneKeyDim\\标高、坡道族、尺寸标注.rvt";
				DimensionType dimensionType = this.LoadDimensionTypeFile(document, strFamilyFilePath, strTypeName);
				if (dimensionType == null)
				{
					result = null;
				}
				else
				{
					result = dimensionType;
				}
			}
			catch (Exception)
			{
				throw;
			}
			return result;
		}

		private DimensionType LoadDimensionTypeFile(Autodesk.Revit.DB.Document doc, string strFamilyFilePath, string strFamilyName)
		{
			DimensionType dimensionType = null;
			if (DrawDoorWindowLegendControler.FindFamily(strFamilyName, out dimensionType, doc))
			{
				return dimensionType;
			}
			Document document = doc.Application.OpenDocumentFile(strFamilyFilePath);
			if (!DrawDoorWindowLegendControler.FindFamily(strFamilyName, out dimensionType, document))
			{
				return dimensionType;
			}
			List<ElementId> list = new List<ElementId>();
			list.Add(dimensionType.Id);
			CopyPasteOptions copyPasteOptions = new CopyPasteOptions();
			copyPasteOptions.SetDuplicateTypeNamesHandler(new HideAndAcceptDuplicateTypeNamesHandler());
			ICollection<ElementId> source = ElementTransformUtils.CopyElements(document, list, doc, Transform.Identity, copyPasteOptions);
			return doc.GetElement(source.ElementAt(0)) as DimensionType;
		}

		private static bool FindFamily(string strFamilyName, out DimensionType dimensionType, Autodesk.Revit.DB.Document doc)
		{
			FilteredElementCollector filteredElementCollector = new FilteredElementCollector(doc);
			List<DimensionType> list = filteredElementCollector.OfClass(typeof(DimensionType)).WhereElementIsElementType().Cast<DimensionType>().ToList<DimensionType>();
			if (filteredElementCollector != null)
			{
				filteredElementCollector.ToElements();
				foreach (DimensionType dimensionType2 in list)
				{
					if (dimensionType2.Name == strFamilyName)
					{
						dimensionType = dimensionType2;
						return true;
					}
				}
			}
			dimensionType = null;
			return false;
		}

		public Result Refresh(WindowHandle hWndRevit, List<Group> lstUseGroups, ref string message)
		{
			Document document = this.m_Revit.Application.ActiveUIDocument.Document;
			List<FamilyInstance> list = new List<FamilyInstance>();
			List<KeyValuePair<int, string>> list2 = new List<KeyValuePair<int, string>>();
			List<FamilyInstance> allDoorDelegate = this.GetAllDoorDelegate(ref list2);
			List<FamilyInstance> allWindowDelegate = this.GetAllWindowDelegate(ref list2);
			list.AddRange(allDoorDelegate);
			list.AddRange(allWindowDelegate);
			double maxLegendWidth = this.GetMaxLegendWidth(allDoorDelegate, allWindowDelegate);
			Transaction transaction = new Transaction(document, "Refresh");
			transaction.Start();
			List<FamilyInstance> lstModifyFis = new List<FamilyInstance>();
			List<FamilyInstance> list3 = new List<FamilyInstance>();
			Dictionary<int, Group> dictionary = new Dictionary<int, Group>();
			Dictionary<FamilyInstance, List<Dimension>> dictionary2 = new Dictionary<FamilyInstance, List<Dimension>>();
			Dictionary<FamilyInstance, List<Dimension>> dictionary3 = new Dictionary<FamilyInstance, List<Dimension>>();
			Dictionary<FamilyInstance, List<Dimension>> dictionary4 = new Dictionary<FamilyInstance, List<Dimension>>();
			this.DeleteGroup(document, list, lstUseGroups, ref dictionary);
			this.GetNeedNewFamilyInstance(list, dictionary, ref lstModifyFis, ref list3);
			this.GetModifyFamilyInstance(document, lstModifyFis, dictionary, ref dictionary2);
			transaction.Commit();
			foreach (FamilyInstance key in list3)
			{
				dictionary2.Add(key, null);
			}
			foreach (KeyValuePair<FamilyInstance, List<Dimension>> keyValuePair in dictionary2)
			{
				if (keyValuePair.Key != null && keyValuePair.Key.Category.Id.IntegerValue == -2000023)
				{
					dictionary3.Add(keyValuePair.Key, keyValuePair.Value);
				}
				else if (keyValuePair.Key != null && keyValuePair.Key.Category.Id.IntegerValue == -2000014)
				{
					dictionary4.Add(keyValuePair.Key, keyValuePair.Value);
				}
			}
			if (dictionary3.Count == 0 && dictionary4.Count == 0)
			{
				YJKMessageBox.Show("刷新门窗图例已更新完成。");
				return Autodesk.Revit.UI.Result.Succeeded;
			}
			this.ZoomView(maxLegendWidth);
			PickedBox pickedBox = this.SelectPickedBox();
			if (pickedBox == null)
			{
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			double x = pickedBox.Min.X;
			double x2 = pickedBox.Max.X;
			if (YJKExcelFormTool.Utilities.Geometry.LessThan(x2, x))
			{
				x = pickedBox.Max.X;
				x2 = pickedBox.Min.X;
			}
			double y = pickedBox.Min.Y;
			double y2 = pickedBox.Max.Y;
			if (YJKExcelFormTool.Utilities.Geometry.LessThan(y2, y))
			{
				y = pickedBox.Max.Y;
				y2 = pickedBox.Min.Y;
			}
			XYZ xyz = new XYZ(x, y2, 0.0);
			double num = x2 - x;
			double dimOffset = this.m_DimOffset;
			double extendCol = this.m_DimOffset + this.m_FontHeight;
			if (num < maxLegendWidth + dimOffset * 2.0)
			{
				YJKMessageBox.Show("宽度不够");
				return Autodesk.Revit.UI.Result.Cancelled;
			}
			Transaction transaction2 = new Transaction(document);
			transaction2.Start("create legend");
			List<KeyValuePair<int, string>> list4 = new List<KeyValuePair<int, string>>();
			KeyValuePair<int, string> item = new KeyValuePair<int, string>(allDoorDelegate.Count, "提取门图例信息");
			list4.Add(item);
			KeyValuePair<int, string> item2 = new KeyValuePair<int, string>(allWindowDelegate.Count, "提取窗图例信息");
			list4.Add(item2);
			KeyValuePair<int, string> item3 = new KeyValuePair<int, string>(allDoorDelegate.Count, "绘制门图例");
			list4.Add(item3);
			KeyValuePair<int, string> item4 = new KeyValuePair<int, string>(allWindowDelegate.Count, "绘制窗图例");
			list4.Add(item4);
			MyProgressBar myProgressBar = new MyProgressBar(hWndRevit, list4, "绘制门窗图例", true);
			double scale = 1.0;
			List<DrawDoorWindowLegendControler.LegendRowInfos> legendTableInfos = this.GetLegendTableInfos(dictionary3, num, dimOffset, scale, ref myProgressBar);
			List<DrawDoorWindowLegendControler.LegendRowInfos> legendTableInfos2 = this.GetLegendTableInfos(dictionary4, num, dimOffset, scale, ref myProgressBar);
			DrawDoorWindowLegendControler.BlockInput(true);
			XYZ xyz2 = this.CreateLegends(legendTableInfos, xyz, dimOffset, extendCol, ref myProgressBar);
			xyz2 = this.CreateLegends(legendTableInfos2, xyz + xyz2, dimOffset, extendCol, ref myProgressBar);
			DrawDoorWindowLegendControler.BlockInput(false);
			if (myProgressBar.IsStoped)
			{
				transaction2.RollBack();
			}
			else
			{
				transaction2.Commit();
			}
			myProgressBar.Dispose();
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private void ZoomView(double maxLegendWidth)
		{
			Document document = this.m_Revit.Application.ActiveUIDocument.Document;
			Transaction transaction = new Transaction(document);
			transaction.Start("add reference line");
			XYZ zero = XYZ.Zero;
			XYZ xyz = new XYZ(maxLegendWidth * 20.0, 0.0, 0.0);
			XYZ xyz2 = new XYZ(maxLegendWidth * 20.0, maxLegendWidth * 10.0, 0.0);
			XYZ xyz3 = new XYZ(0.0, maxLegendWidth * 10.0, 0.0);
			CurveArray curveArray = new CurveArray();
			Line line = YJKLineEx.YJKGetBound(zero, xyz);
			curveArray.Append(line);
			Line line2 = YJKLineEx.YJKGetBound(xyz, xyz2);
			curveArray.Append(line2);
			Line line3 = YJKLineEx.YJKGetBound(xyz2, xyz3);
			curveArray.Append(line3);
			Line line4 = YJKLineEx.YJKGetBound(xyz3, zero);
			curveArray.Append(line4);
			Autodesk.Revit.DB.View activeView = this.m_Revit.Application.ActiveUIDocument.ActiveView;
			DetailCurveArray detailCurveArray = document.Create.NewDetailCurveArray(activeView, curveArray);
			List<ElementId> list = new List<ElementId>();
			foreach (object obj in detailCurveArray)
			{
				DetailCurve detailCurve = (DetailCurve)obj;
				list.Add(detailCurve.Id);
			}
			transaction.Commit();
			this.m_Revit.Application.ActiveUIDocument.ShowElements(list);
			Transaction transaction2 = new Transaction(document);
			transaction2.Start("delete reference line");
			foreach (object obj2 in detailCurveArray)
			{
				DetailCurve detailCurve2 = (DetailCurve)obj2;
				document.Delete(detailCurve2.Id);
			}
			transaction2.Commit();
		}

		private FillPatternElement GetSolidPattern(string patternName)
		{
			foreach (Element element in new FilteredElementCollector(this.m_Revit.Application.ActiveUIDocument.Document).OfClass(typeof(FillPatternElement)).ToElements())
			{
				FillPatternElement fillPatternElement = element as FillPatternElement;
				if (fillPatternElement != null && fillPatternElement.Name.CompareTo(patternName) == 0)
				{
					return fillPatternElement;
				}
			}
			return null;
		}

		private ElementId GetFilledRegionTypeId()
		{
			IList<Element> list = new FilteredElementCollector(this.m_Revit.Application.ActiveUIDocument.Document).OfClass(typeof(FilledRegionType)).ToElements();
			string text = "HY_实体填充";
			foreach (Element element in list)
			{
				FilledRegionType filledRegionType = element as FilledRegionType;
				if (filledRegionType != null && filledRegionType.Name.CompareTo(text) == 0)
				{
					return filledRegionType.Id;
				}
			}
			if (list.Count < 1)
			{
				return null;
			}
			FilledRegionType filledRegionType2 = (list[0] as FilledRegionType).Duplicate(text) as FilledRegionType;
			if (filledRegionType2 == null)
			{
				return null;
			}
			FillPatternElement solidPattern = this.GetSolidPattern("实体填充");
			if (solidPattern != null)
			{
				RevitVersionFuncs.SetFillPatternId(ref filledRegionType2, solidPattern.Id);
			}
			try
			{
				RevitVersionFuncs.SetFillRegionColor(ref filledRegionType2, new Autodesk.Revit.DB.Color(byte.MaxValue, byte.MaxValue, byte.MaxValue));
			}
			catch (Exception)
			{
				return filledRegionType2.Id;
			}
			return filledRegionType2.Id;
		}

		private XYZ CreateLegends(List<DrawDoorWindowLegendControler.LegendRowInfos> rowList, XYZ position, double extendRow, double extendCol, ref MyProgressBar myProgress)
		{
			ElementId filledRegionTypeId = this.GetFilledRegionTypeId();
			XYZ xyz = position;
			for (int i = 0; i < rowList.Count; i++)
			{
				DrawDoorWindowLegendControler.LegendRowInfos legendRowInfos = rowList[i];
				XYZ xyz2 = -XYZ.BasisY * (legendRowInfos.m_RowHeight / 2.0 + extendCol);
				xyz += xyz2;
				XYZ xyz3 = xyz;
				for (int j = 0; j < legendRowInfos.m_LegendInfosList.Count; j++)
				{
					List<ElementId> list = new List<ElementId>();
					XYZ xyz4 = XYZ.BasisX * (legendRowInfos.m_LegendInfosList[j].Width() / 2.0 + extendRow);
					xyz3 += xyz4;
					XYZ pt = xyz3;
					BoundingBoxUV boundingBox = legendRowInfos.m_LegendInfosList[j].m_BoundingBox;
					UV uv = boundingBox.Min + (boundingBox.Max - boundingBox.Min) / 2.0;
					XYZ xyz5 = new XYZ(uv.U, uv.V, 0.0);
					XYZ offset = xyz3 - xyz5;
					ElementId elementId = null;
					string groupName = legendRowInfos.m_LegendInfosList[j].m_FamilyName + ";" + legendRowInfos.m_LegendInfosList[j].m_SymbolName;
					List<List<List<Curve>>> faceEdgeLoopList = legendRowInfos.m_LegendInfosList[j].m_FaceEdgeLoopList;
					DrawLegendKit.DrawFilledRegionAndCreateGroup(this.m_Revit, filledRegionTypeId, faceEdgeLoopList, offset, groupName, ref elementId);
					if (legendRowInfos.m_LegendInfosList[j].m_lstDimensions == null)
					{
						list = this.DrawDimention(boundingBox, this.m_DimensionType, offset, this.m_DimOffset);
					}
					string symbolName = legendRowInfos.m_LegendInfosList[j].m_SymbolName;
					ElementId invalidElementId = ElementId.InvalidElementId;
					this.DrawText(boundingBox, this.m_TextNoteType, symbolName, offset, this.m_DimOffset, this.m_FontHeight, this.m_FontRate, ref invalidElementId);
					xyz3 += xyz4;
					list.Add(invalidElementId);
					Document document = this.m_Revit.Application.ActiveUIDocument.Document;
					string winOrDoorInfo = this.GetWinOrDoorInfo(document.GetElement(legendRowInfos.m_LegendInfosList[j].m_CurElemId) as FamilySymbol);
					Group ele = document.GetElement(elementId) as Group;
					InsertDataToGroup.WirteDataToGroup(document, ele, legendRowInfos.m_LegendInfosList[j].m_CurElemId.ToString(), winOrDoorInfo, pt, list);
					if (!myProgress.ProgressStep(1) && myProgress.IsStoped)
					{
						break;
					}
				}
				xyz += xyz2;
			}
			return new XYZ(0.0, xyz.Y - position.Y, 0.0);
		}

		private string GetWinOrDoorInfo(FamilySymbol fi)
		{
			Parameter parameter = fi.get_Parameter(BuiltInParameter.CASEWORK_WIDTH);
			Parameter parameter2 = fi.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM);
			if (parameter == null || parameter2 == null || (int)parameter.StorageType != 2 || (int)parameter2.StorageType != 2)
			{
				return "";
			}
			double num = parameter2.AsDouble();
			double num2 = parameter.AsDouble();
			return num.ToString() + "," + num2.ToString();
		}

		private void CreateLegend(DrawDoorWindowLegendControler.LegendInfos legendInfos, XYZ position)
		{
			ElementId filledRegionTypeId = this.GetFilledRegionTypeId();
			int scale = this.m_Revit.Application.ActiveUIDocument.ActiveView.Scale;
			XYZ xyz = -XYZ.BasisY * (legendInfos.Height() / 2.0) * (double)(scale / 100);
			position += xyz;
			XYZ xyz2 = XYZ.BasisX * (legendInfos.Width() / 2.0) * (double)(scale / 100);
			position += xyz2;
			BoundingBoxUV boundingBox = legendInfos.m_BoundingBox;
			UV uv = boundingBox.Min + (boundingBox.Max - boundingBox.Min) / 2.0;
			XYZ xyz3 = new XYZ(uv.U, uv.V, 0.0);
			XYZ offset = position - xyz3;
			ElementId elementId = null;
			string groupName = legendInfos.m_FamilyName + ";" + legendInfos.m_SymbolName;
			List<List<List<Curve>>> faceEdgeLoopList = legendInfos.m_FaceEdgeLoopList;
			DrawLegendKit.DrawFilledRegionAndCreateGroup(this.m_Revit, filledRegionTypeId, faceEdgeLoopList, offset, groupName, ref elementId);
			this.DrawDimention(boundingBox, this.m_DimensionType, offset, this.m_DimOffset);
			string comments = legendInfos.m_Comments;
			ElementId invalidElementId = ElementId.InvalidElementId;
			this.DrawText(boundingBox, this.m_TextNoteType, comments, offset, this.m_DimOffset, this.m_FontHeight, this.m_FontRate, ref invalidElementId);
			this.UpdateModel(this.m_Revit.Application.ActiveUIDocument, false);
		}

		public void UpdateModel(UIDocument uiDoc, bool autoJoin)
		{
			uiDoc.Document.Regenerate();
			if (autoJoin)
			{
				uiDoc.Document.AutoJoinElements();
			}
			uiDoc.RefreshActiveView();
		}

		private string GetTagTextOfDWH(Autodesk.Revit.DB.Document doc, FamilyInstance familyInstance)
		{
			ElementId typeId = familyInstance.GetTypeId();
			string result = "未标记";
			FamilySymbol familySymbol = RevitVersionFuncs.GetElement(doc, typeId) as FamilySymbol;
			if (familySymbol != null)
			{
				result = this.GetTagTextOfDWH(doc, familySymbol);
			}
			return result;
		}

		private string GetTagTextOfDWH(Autodesk.Revit.DB.Document doc, FamilySymbol familySymbol)
		{
			string result = "未标记";
			if (familySymbol != null)
			{
				Parameter parameter = familySymbol.GetParameter("类型标记");
				if (parameter != null && parameter.HasValue)
				{
					result = parameter.AsString();
				}
			}
			return result;
		}

		private void GetModifyFamilyInstance(Autodesk.Revit.DB.Document doc, List<FamilyInstance> lstModifyFis, Dictionary<int, Group> dicGroup, ref Dictionary<FamilyInstance, List<Dimension>> lstUseRefreshFis)
		{
			List<ElementId> list = new List<ElementId>();
			new List<ElementId>();
			foreach (FamilyInstance familyInstance in lstModifyFis)
			{
				try
				{
					int integerValue = familyInstance.GetTypeId().IntegerValue;
					string winOrDoorInfo = this.GetWinOrDoorInfo(familyInstance.Symbol);
					object obj = InsertDataToGroup.ReadInfoFormGroup(doc, dicGroup[integerValue], "DoorWindowInfo");
					if (obj != null && obj is string && !winOrDoorInfo.Equals(obj as string))
					{
						object obj2 = InsertDataToGroup.ReadInfoFormGroup(doc, dicGroup[integerValue], "OtherEleId");
						if (obj2 != null && obj2 is List<ElementId>)
						{
							list.AddRange(obj2 as List<ElementId>);
						}
						list.Add(dicGroup[integerValue].Id);
						List<Dimension> list2 = new List<Dimension>();
						this.GetCurGroupRangeDim(doc, dicGroup[integerValue], ref list2);
						foreach (Dimension dimension in list2)
						{
							list.Add(dimension.Id);
						}
						doc.Delete(list);
						lstUseRefreshFis.Add(familyInstance, null);
					}
				}
				catch (Exception)
				{
				}
			}
		}

		private void GetNeedNewFamilyInstance(List<FamilyInstance> lstCurDoorAndWin, Dictionary<int, Group> dicDimension, ref List<FamilyInstance> lstModifyFis, ref List<FamilyInstance> lstUseRefreshFamilyInstance)
		{
			foreach (FamilyInstance familyInstance in lstCurDoorAndWin)
			{
				try
				{
					if (!dicDimension.ContainsKey(familyInstance.GetTypeId().IntegerValue))
					{
						lstUseRefreshFamilyInstance.Add(familyInstance);
					}
					else
					{
						lstModifyFis.Add(familyInstance);
					}
				}
				catch (Exception)
				{
				}
			}
		}

		private void DeleteGroup(Autodesk.Revit.DB.Document doc, List<FamilyInstance> lstDoorAndWin, List<Group> lstUseGroups, ref Dictionary<int, Group> dicGroup)
		{
			List<int> list = new List<int>();
			List<ElementId> list2 = new List<ElementId>();
			foreach (FamilyInstance familyInstance in lstDoorAndWin)
			{
				list.Add(familyInstance.GetTypeId().IntegerValue);
			}
			foreach (Group group in lstUseGroups)
			{
				int num = -1;
				object obj = InsertDataToGroup.ReadInfoFormGroup(doc, group, "DoorWindowId");
				if (obj != null && obj is string)
				{
					num = int.Parse(obj as string);
				}
				if (!list.Contains(num) && num != -1)
				{
					object obj2 = InsertDataToGroup.ReadInfoFormGroup(doc, group, "OtherEleId");
					if (obj2 != null && obj2 is List<ElementId>)
					{
						list2.AddRange(obj2 as List<ElementId>);
					}
					list2.Add(group.Id);
					List<Dimension> list3 = new List<Dimension>();
					this.GetCurGroupRangeDim(doc, group, ref list3);
					using (List<Dimension>.Enumerator enumerator3 = list3.GetEnumerator())
					{
						while (enumerator3.MoveNext())
						{
							Dimension dimension = enumerator3.Current;
							list2.Add(dimension.Id);
						}
						continue;
					}
				}
				try
				{
					dicGroup.Add(num, group);
				}
				catch (Exception)
				{
				}
			}
			doc.Delete(list2);
		}

		private void GetAllDimensionofCurDoc(Autodesk.Revit.DB.Document doc, ref Dictionary<int, List<ElementId>> dicDimension)
		{
			List<Dimension> list = (from d in new FilteredElementCollector(doc).OfClass(typeof(Dimension)).OfCategory(BuiltInCategory.OST_Dimensions)
			select d as Dimension).ToList<Dimension>();
			try
			{
				foreach (Dimension dimension in list)
				{
					object obj = InsertDataToGroup.ReadInfoFormGroup(doc, dimension, "DoorWindowId");
					if (obj != null && obj is string)
					{
						int key = int.Parse(obj as string);
						if (!dicDimension.ContainsKey(key))
						{
							List<ElementId> list2 = new List<ElementId>();
							list2.Add(dimension.Id);
							dicDimension.Add(key, list2);
						}
						else
						{
							dicDimension[key].Add(dimension.Id);
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private void GetCurGroupRangeDim(Autodesk.Revit.DB.Document doc, Group curGroup, ref List<Dimension> lstRangeDim)
		{
			double num = 0.0;
			double num2 = 0.0;
			double num3 = 1200.0;
			XYZ xyz = null;
			string text = string.Empty;
			try
			{
				object obj = InsertDataToGroup.ReadInfoFormGroup(doc, curGroup, "DoorWinInsertPt");
				if (obj != null && obj is XYZ)
				{
					xyz = (obj as XYZ);
				}
				object obj2 = InsertDataToGroup.ReadInfoFormGroup(doc, curGroup, "DoorWindowInfo");
				if (obj2 != null && obj2 is string)
				{
					text = (obj2 as string);
				}
				string[] array = text.Split(new char[]
				{
					','
				});
				num2 = double.Parse(array[0]);
				num = double.Parse(array[1]);
			}
			catch (Exception)
			{
				YJKMessageBox.Show("构建搜索区域失败!");
				return;
			}
			XYZ xyz2 = XYZ.BasisX.Negate() * (AssistFunc.mmToFeet(num3) + num / 2.0);
			XYZ xyz3 = xyz + xyz2;
			XYZ xyz4 = XYZ.BasisY * (AssistFunc.mmToFeet(num3) + num2 / 2.0);
			XYZ xyz5 = xyz3 + xyz4;
			XYZ xyz6 = xyz5 + XYZ.BasisY.Negate() * (AssistFunc.mmToFeet(num3 * 2.0) + num2);
			XYZ xyz7 = xyz6 + XYZ.BasisX * (AssistFunc.mmToFeet(num3 * 2.0) + num);
			XYZ xyz8 = xyz7 + XYZ.BasisY * (AssistFunc.mmToFeet(num3 * 2.0) + num2);
			List<Curve> list = new List<Curve>();
			list.Add(Line.CreateBound(xyz5, xyz6));
			list.Add(Line.CreateBound(xyz6, xyz7));
			list.Add(Line.CreateBound(xyz7, xyz8));
			list.Add(Line.CreateBound(xyz8, xyz5));
			foreach (Dimension dimension in (from d in new FilteredElementCollector(doc).OfClass(typeof(Dimension)).OfCategory(BuiltInCategory.OST_Dimensions)
			select d as Dimension).ToList<Dimension>())
			{
				DimensionSegmentArray segments = dimension.Segments;
				XYZ textPosition;
				if (segments.Size != 0)
				{
					textPosition = segments.get_Item(0).TextPosition;
				}
				else
				{
					textPosition = dimension.TextPosition;
				}
				if (dimension != null && YJKGeometryFuncs.Geometry.PointInPloygon(list, textPosition) == 1)
				{
					lstRangeDim.Add(dimension);
				}
			}
		}

		private List<DrawDoorWindowLegendControler.LegendRowInfos> GetLegendTableInfos(Dictionary<FamilyInstance, List<Dimension>> doorWindowList, double pickBoxWidth, double extendRow, double scale, ref MyProgressBar myProgress)
		{
            ViewDetailLevel detailLevel = (ViewDetailLevel)1;
			Document document = this.m_Revit.Application.ActiveUIDocument.Document;
			List<DrawDoorWindowLegendControler.LegendInfos> list = new List<DrawDoorWindowLegendControler.LegendInfos>();
			int i;
			for (i = 0; i < doorWindowList.Count; i++)
			{
				KeyValuePair<FamilyInstance, List<Dimension>> keyValuePair = doorWindowList.ElementAt(i);
				DrawLegendKit drawLegendKit = new DrawLegendKit(this.m_Revit, keyValuePair.Key.Symbol, DrawLegendKit.ViewSectionType.VST_Front, detailLevel, XYZ.Zero);
				List<List<List<Curve>>> list2 = new List<List<List<Curve>>>();
				if (drawLegendKit.GetLegendEdgeLoopList(scale, true, true, ref list2) != Result.Succeeded)
				{
					if (!myProgress.ProgressStep(1) && myProgress.IsStoped)
					{
						break;
					}
				}
				else
				{
					if (drawLegendKit.BoundingBox != null && list2.Count > 0)
					{
						DrawDoorWindowLegendControler.LegendInfos item = default(DrawDoorWindowLegendControler.LegendInfos);
						item.m_Comments = this.GetTagTextOfDWH(document, keyValuePair.Key);
						item.m_FamilyName = keyValuePair.Key.Symbol.Family.Name;
						item.m_SymbolName = keyValuePair.Key.Symbol.Name;
						item.m_CurElemId = keyValuePair.Key.GetTypeId();
						item.m_lstDimensions = keyValuePair.Value;
						item.m_FaceEdgeLoopList = list2;
						BoundingBoxUV boundingBox = drawLegendKit.BoundingBox;
						item.m_BoundingBox = boundingBox;
						list.Add(item);
					}
					if (!myProgress.ProgressStep(1) && myProgress.IsStoped)
					{
						break;
					}
				}
			}
			list.Sort(new DrawDoorWindowLegendControler.AreaComparer());
			List<DrawDoorWindowLegendControler.LegendRowInfos> list3 = new List<DrawDoorWindowLegendControler.LegendRowInfos>();
			double num = 0.0;
			double num2 = 0.0;
			List<DrawDoorWindowLegendControler.LegendInfos> list4 = new List<DrawDoorWindowLegendControler.LegendInfos>();
			i = 0;
			while (i < list.Count)
			{
				num2 += list[i].Width() + extendRow * 2.0;
				if (num2 <= pickBoxWidth)
				{
					goto IL_241;
				}
				DrawDoorWindowLegendControler.LegendRowInfos legendRowInfos = new DrawDoorWindowLegendControler.LegendRowInfos
				{
					m_RowHeight = num,
					m_LegendInfosList = new List<DrawDoorWindowLegendControler.LegendInfos>()
				};
				legendRowInfos.m_LegendInfosList.AddRange(list4);
				legendRowInfos.m_CurElemId = list[i].m_CurElemId;
				legendRowInfos.m_lstDimensions = list[i].m_lstDimensions;
				list3.Add(legendRowInfos);
				num = 0.0;
				num2 = 0.0;
				list4.Clear();
				if (list4.Count <= 0)
				{
					goto IL_241;
				}
				i--;
				IL_2DA:
				i++;
				continue;
				IL_241:
				if (num < list[i].Height())
				{
					num = list[i].Height();
				}
				list4.Add(list[i]);
				if (i == list.Count - 1)
				{
					DrawDoorWindowLegendControler.LegendRowInfos legendRowInfos2 = new DrawDoorWindowLegendControler.LegendRowInfos
					{
						m_RowHeight = num,
						m_CurElemId = list[i].m_CurElemId,
						m_lstDimensions = list[i].m_lstDimensions,
						m_LegendInfosList = new List<DrawDoorWindowLegendControler.LegendInfos>()
					};
					legendRowInfos2.m_LegendInfosList.AddRange(list4);
					list3.Add(legendRowInfos2);
					goto IL_2DA;
				}
				goto IL_2DA;
			}
			return list3;
		}

		private DrawDoorWindowLegendControler.LegendInfos GetLegendInfos(FamilySymbol doorWindowType, DrawLegendKit.ViewSectionType vsType, double scale)
		{
            ViewDetailLevel detailLevel = (ViewDetailLevel)1;
			Document document = this.m_Revit.Application.ActiveUIDocument.Document;
			new List<DrawDoorWindowLegendControler.LegendInfos>();
			DrawLegendKit drawLegendKit = new DrawLegendKit(this.m_Revit, doorWindowType, vsType, detailLevel, XYZ.Zero);
			List<List<List<Curve>>> list = new List<List<List<Curve>>>();
			if (drawLegendKit.GetLegendEdgeLoopList(scale, true, true, ref list) != Result.Succeeded || drawLegendKit.BoundingBox == null || list.Count < 1)
			{
				return default(DrawDoorWindowLegendControler.LegendInfos);
			}
			DrawDoorWindowLegendControler.LegendInfos result = default(DrawDoorWindowLegendControler.LegendInfos);
			result.m_Comments = this.GetTagTextOfDWH(document, doorWindowType);
			result.m_FamilyName = doorWindowType.Family.Name;
			result.m_SymbolName = doorWindowType.Name;
			result.m_FaceEdgeLoopList = list;
			BoundingBoxUV boundingBox = drawLegendKit.BoundingBox;
			result.m_BoundingBox = boundingBox;
			return result;
		}

		private DimensionType GetDimentionType(ref double offsetLength)
		{
			IEnumerable<Element> enumerable = new FilteredElementCollector(this.m_Revit.Application.ActiveUIDocument.Document).OfClass(typeof(DimensionType)).ToElements();
			List<DimensionType> list = new List<DimensionType>();
			DimensionType dimensionType = null;
			foreach (Element element in enumerable)
			{
				DimensionType dimensionType2 = element as DimensionType;
                if (dimensionType2.StyleType == DimensionStyleType.Linear)
				{
					list.Add(dimensionType2);
					if (element.Name.CompareTo("对角线-3mm RomanD") == 0)
					{
						dimensionType = (element as DimensionType);
						break;
					}
				}
			}
			if (dimensionType == null)
			{
				if (list.Count < 1)
				{
					throw new Exception("dimentionType is null!");
				}
				dimensionType = list[0];
			}
			Parameter parameter = dimensionType.get_Parameter(BuiltInParameter.DIM_WITNS_LINE_EXTENSION_BELOW);
			Parameter parameter2 = dimensionType.get_Parameter(BuiltInParameter.WITNS_LINE_EXTENSION);
			offsetLength = parameter.AsDouble() + parameter2.AsDouble();
			offsetLength *= (double)this.m_Revit.Application.ActiveUIDocument.ActiveView.Scale;
			return dimensionType;
		}

		private TextNoteType GetTextNoteType(ref double m_FontHeight, ref double m_FontRate)
		{
			IList<Element> list = new FilteredElementCollector(this.m_Revit.Application.ActiveUIDocument.Document).OfClass(typeof(TextNoteType)).ToElements();
			TextNoteType textNoteType = null;
			foreach (Element element in list)
			{
				if (element.Name.CompareTo("仿宋 3.5mm") == 0)
				{
					textNoteType = (element as TextNoteType);
					break;
				}
			}
			if (textNoteType == null)
			{
				if (list.Count < 1)
				{
					throw new Exception("m_TextNoteType is null!");
				}
				textNoteType = (list[0] as TextNoteType);
			}
			Parameter parameter = textNoteType.get_Parameter(BuiltInParameter.TEXT_SIZE);
			m_FontHeight = parameter.AsDouble() * (double)this.m_Revit.Application.ActiveUIDocument.ActiveView.Scale;
			Parameter parameter2 = textNoteType.get_Parameter(BuiltInParameter.TEXT_WIDTH_SCALE);
			m_FontRate = parameter2.AsDouble();
			return textNoteType;
		}

		private List<ElementId> DrawDimention(BoundingBoxUV boundingBox, DimensionType dimensionType, XYZ offset, double dimOffset)
		{
			XYZ ptStart = new XYZ(boundingBox.Max.U, boundingBox.Max.V, 0.0) + offset;
			XYZ xyz = new XYZ(boundingBox.Max.U, boundingBox.Min.V, 0.0) + offset;
			List<ElementId> result = new List<ElementId>();
			this.DrawDimention(ptStart, xyz, XYZ.BasisX, dimensionType, dimOffset, ref result);
			XYZ ptStart2 = new XYZ(boundingBox.Min.U, boundingBox.Min.V, 0.0) + offset;
			XYZ ptEnd = xyz;
			this.DrawDimention(ptStart2, ptEnd, -XYZ.BasisY, dimensionType, dimOffset, ref result);
			return result;
		}

		private Element DrawDimention(XYZ ptStart, XYZ ptEnd, XYZ dir, DimensionType dimensionType, double dimOffset, ref List<ElementId> lstOneDetailCvs)
		{
			Autodesk.Revit.DB.View activeView = this.m_Revit.Application.ActiveUIDocument.ActiveView;
			ReferenceArray referenceArray = new ReferenceArray();
			XYZ xyz = dir * AssistFunc.mmToFeet(100.0);
			Line line = null;
			if (!this.CreatYJKLine(ptStart, ptStart - xyz, true, ref line))
			{
				return null;
			}
			DetailCurve detailCurve = this.m_Revit.Application.ActiveUIDocument.Document.Create.NewDetailCurve(activeView, line);
			referenceArray.Append(detailCurve.GeometryCurve.Reference);
			lstOneDetailCvs.Add(detailCurve.Id);
			Line line2 = null;
			if (!this.CreatYJKLine(ptEnd, ptEnd - xyz, true, ref line2))
			{
				return null;
			}
			DetailCurve detailCurve2 = this.m_Revit.Application.ActiveUIDocument.Document.Create.NewDetailCurve(activeView, line2);
			referenceArray.Append(detailCurve2.GeometryCurve.Reference);
			lstOneDetailCvs.Add(detailCurve2.Id);
			ptStart += dir * dimOffset;
			ptEnd += dir * dimOffset;
			Line line3 = null;
			if (!this.CreatYJKLine(ptStart, ptEnd, true, ref line3))
			{
				return null;
			}
			DimensionType dimensionType2 = this.GetDimensionType("线性尺寸标注样式", "HY-尺寸标注");
			return this.m_Revit.Application.ActiveUIDocument.Document.Create.NewDimension(activeView, line3, referenceArray, dimensionType2);
		}

		private void DrawText(BoundingBoxUV boundingBox, TextNoteType m_TextNoteType, string name, XYZ offset, double dimOffset, double fontHeight, double fontRate, ref ElementId nTextNoteId)
		{
			XYZ xyz = new XYZ(boundingBox.Min.U + (boundingBox.Max.U - boundingBox.Min.U) / 2.0, boundingBox.Min.V, 0.0);
			xyz += -XYZ.BasisY * (dimOffset + fontHeight * 2.0);
			xyz += offset;
			Document document = this.m_Revit.Application.ActiveUIDocument.Document;
			double lineWidth = fontHeight * fontRate * (double)name.Length / (double)this.m_Revit.Application.ActiveUIDocument.ActiveView.Scale;
			TextNote textNode = document.GetTextNode(document.ActiveView, xyz, new XYZ(1.0, 0.0, 0.0), new XYZ(0.0, 1.0, 0.0), lineWidth, (Autodesk.Revit.DB.TextAlignFlags)1152, name);
			nTextNoteId = textNode.Id;
		}

		private List<FamilyInstance> GetAllDoorDelegate(ref List<KeyValuePair<int, string>> subTypeInfoList)
		{
			List<FamilyInstance> list = new List<FamilyInstance>();
			List<ElementId> list2 = new List<ElementId>();
			foreach (Element element in new FilteredElementCollector(this.m_Revit.Application.ActiveUIDocument.Document).OfCategory(BuiltInCategory.OST_Doors))
			{
				FamilyInstance familyInstance = element as FamilyInstance;
				if (familyInstance != null)
				{
					ElementId typeId = familyInstance.GetTypeId();
					if (list2.FindIndex((ElementId s) => s.IntegerValue == typeId.IntegerValue) < 0)
					{
						list.Add(familyInstance);
						list2.Add(typeId);
					}
				}
			}
			int count = list.Count;
			KeyValuePair<int, string> item = new KeyValuePair<int, string>(count, "门");
			subTypeInfoList.Add(item);
			return list;
		}

		private List<FamilyInstance> GetAllWindowDelegate(ref List<KeyValuePair<int, string>> subTypeInfoList)
		{
			List<FamilyInstance> list = new List<FamilyInstance>();
			List<ElementId> list2 = new List<ElementId>();
			foreach (Element element in new FilteredElementCollector(this.m_Revit.Application.ActiveUIDocument.Document).OfCategory(BuiltInCategory.OST_Windows))
			{
				FamilyInstance familyInstance = element as FamilyInstance;
				if (familyInstance != null)
				{
					ElementId typeId = familyInstance.GetTypeId();
					if (list2.FindIndex((ElementId s) => s.IntegerValue == typeId.IntegerValue) < 0)
					{
						list.Add(familyInstance);
						list2.Add(typeId);
					}
				}
			}
			int count = list.Count;
			KeyValuePair<int, string> item = new KeyValuePair<int, string>(count, "窗");
			subTypeInfoList.Add(item);
			return list;
		}

		private double GetMaxLegendWidth(List<FamilyInstance> doorList, List<FamilyInstance> windowList)
		{
			List<FamilyInstance> list = new List<FamilyInstance>();
			list.AddRange(doorList);
			list.AddRange(windowList);
			double num = 0.0;
			foreach (FamilyInstance familyInstance in list)
			{
				BoundingBoxXYZ boundingBoxXYZ = familyInstance.get_BoundingBox(this.m_Revit.Application.ActiveUIDocument.ActiveView);
				double num2 = Math.Abs(boundingBoxXYZ.Max.X - boundingBoxXYZ.Min.X);
				if (num2 > num)
				{
					num = num2;
				}
			}
			return num;
		}

		private void DrawCellFrame(XYZ center, double width, double height)
		{
			XYZ xyz = new XYZ(width / 2.0, 0.0, 0.0);
			XYZ xyz2 = new XYZ(0.0, height / 2.0, 0.0);
			XYZ ptStart = center - xyz - xyz2;
			XYZ ptEnd = center + xyz - xyz2;
			XYZ ptEnd2 = center - xyz + xyz2;
			XYZ ptStart2 = center + xyz + xyz2;
			this.DrawModelLine(ptStart, ptEnd);
			this.DrawModelLine(ptStart, ptEnd2);
			this.DrawModelLine(ptStart2, ptEnd);
			this.DrawModelLine(ptStart2, ptEnd2);
		}

		private void DrawModelLine(XYZ ptStart, XYZ ptEnd)
		{
			Line line = null;
			if (!this.CreatYJKLine(ptStart, ptEnd, true, ref line))
			{
				return;
			}
			Autodesk.Revit.DB.View activeView = this.m_Revit.Application.ActiveUIDocument.ActiveView;
			this.m_Revit.Application.ActiveUIDocument.Document.Create.NewDetailCurve(activeView, line);
		}

		private bool CreatYJKLine(XYZ ptStart, XYZ ptEnd, bool bound, ref Line line)
		{
			if (YJKExcelFormTool.Utilities.Geometry.LessThan(ptStart.DistanceTo(ptEnd), Common.MMToFeet(0.8)))
			{
				return false;
			}
			line = this.m_Revit.Application.ActiveUIDocument.Document.CreatYJKLine(ptStart, ptEnd, bound);
			return true;
		}

		private PickedBox SelectPickedBox()
		{
			PickedBox result = null;
			try
			{
				result = this.m_Revit.Application.ActiveUIDocument.Selection.PickBox((Autodesk.Revit.UI.Selection.PickBoxStyle)0, "框选出图区域");
			}
			catch (Exception)
			{
				return null;
			}
			return result;
		}

		private XYZ SetPositionPoint()
		{
			XYZ xyz = null;
			try
			{
				xyz = this.m_Revit.Application.ActiveUIDocument.Selection.PickPoint("选取出图左上角点");
			}
			catch (Exception)
			{
				return null;
			}
			return new XYZ(xyz.X, xyz.Y, 0.0);
		}

		private double m_DimOffset;

		private DimensionType m_DimensionType;

		private double m_FontHeight = 1.0;

		private double m_FontRate = 1.0;

		private TextNoteType m_TextNoteType;

		private ExternalCommandData m_Revit;

		private struct LegendInfos
		{
			public double Width()
			{
				return Math.Abs(this.m_BoundingBox.Max.U - this.m_BoundingBox.Min.U);
			}

			public double Height()
			{
				return Math.Abs(this.m_BoundingBox.Max.V - this.m_BoundingBox.Min.V);
			}

			public double Area()
			{
				return this.Width() * this.Height();
			}

			public bool IsNull()
			{
				return this.m_BoundingBox == null || this.m_FaceEdgeLoopList.Count == 0;
			}

			public string m_Comments;

			public string m_FamilyName;

			public string m_SymbolName;

			public ElementId m_CurElemId;

			public List<Dimension> m_lstDimensions;

			public BoundingBoxUV m_BoundingBox;

			public List<List<List<Curve>>> m_FaceEdgeLoopList;
		}

		private struct LegendRowInfos
		{
			public bool IsNull()
			{
				return this.m_LegendInfosList.Count < 1;
			}

			public double m_RowHeight;

			public ElementId m_CurElemId;

			public List<Dimension> m_lstDimensions;

			public List<DrawDoorWindowLegendControler.LegendInfos> m_LegendInfosList;
		}

		private class AreaComparer : IComparer<DrawDoorWindowLegendControler.LegendInfos>
		{
			public int Compare(DrawDoorWindowLegendControler.LegendInfos x, DrawDoorWindowLegendControler.LegendInfos y)
			{
				return -x.Area().CompareTo(y.Area());
			}
		}
	}
}
